package com.bocai.freeman.view.fragments;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bocai.freeman.R;
import com.bocai.freeman.base.BaseFragment;
import com.bocai.freeman.view.activitys.MySkillsActivity;
import com.bocai.freeman.view.activitys.MyWalletActivity;
import com.bocai.freeman.view.activitys.PersonCenterMyActivity;
import com.bocai.freeman.view.activitys.SettingActivity;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 我的Frag
 */
public class MeFrag extends BaseFragment {

    @Bind(R.id.iv_icon)
    ImageView mIvIcon;
    @Bind(R.id.tv_name)
    TextView mTvName;
    @Bind(R.id.tv_age)
    TextView mTvAge;
    @Bind(R.id.iv_level)
    ImageView mIvLevel;
    @Bind(R.id.tv_attention_num)
    TextView mTvAttentionNum;
    @Bind(R.id.tv_fans_num)
    TextView mTvFansNum;
    @Bind(R.id.rl_my_wallet)
    RelativeLayout mRlMyWallet;
    @Bind(R.id.rl_my_skill)
    RelativeLayout mRlMySkill;
    @Bind(R.id.rl_request_session)
    RelativeLayout mRlRequestSession;
    @Bind(R.id.rl_skill_session)
    RelativeLayout mRlSkillSession;
    @Bind(R.id.rl_reviews)
    RelativeLayout mRlReviews;
    @Bind(R.id.rl_my_invite)
    RelativeLayout mRlMyInvite;
    @Bind(R.id.tv_balance)
    TextView mTvBalance;
    @Bind(R.id.tv_member)
    TextView mTvMember;
    @Bind(R.id.tv_integral)
    TextView mTvIntegral;

    View view;
    @Bind(R.id.title)
    TextView title;
    @Bind(R.id.toolbar)
    Toolbar toolbar;
    @Bind(R.id.ll_person_center)
    LinearLayout llPersonCenter;
//    @Bind(R.id.iv_set)
//    ImageView mIvSet;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_me, null);
        ButterKnife.bind(this, view);
        initView();
        initEvent();
        return view;
    }

    @Override
    public void initEvent() {
        toolbar.setNavigationIcon(R.mipmap.set);
        toolbar.setNavigationOnClickListener(v -> startActivity(new Intent(getActivity(), SettingActivity.class)));
        toolbar.inflateMenu(R.menu.menu_news);
        toolbar.setOnMenuItemClickListener(item -> {
            return true;
        });
        click(mRlMyWallet).subscribe(o -> startActivity(new Intent(getContext(), MyWalletActivity.class)));
        click(mRlRequestSession).subscribe(o -> {
        });
        click(mRlSkillSession).subscribe(o -> {
        });
        click(mRlReviews).subscribe(o -> {
        });
        click(mRlMySkill).subscribe(o -> {
            startActivity(new Intent(getContext(), MySkillsActivity.class));
        });
        click(mRlMyInvite).subscribe(o -> {
        });
        click(llPersonCenter).subscribe(o -> startActivity(new Intent(getActivity(), PersonCenterMyActivity.class)));
//        click(mIvSet).subscribe(o -> startActivity(new Intent(getActivity(), SettingActivity.class)));
    }


    private void initView() {
        initToolbar();
    }

    private void initToolbar() {
        title.setText("我");
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @Override
    public void setData(Object obj) {

    }
}
